package com.example.application4.pojo;

import androidx.annotation.NonNull;

public class Diary {
    public static int DEFAULT_ID = 0;
    private final int id; // id
    private int userId;
    private String title;
    private String content;
    private String date;

    public Diary(int userId, String title, String content, String date) {
        this.id = DEFAULT_ID++; // 获取并自增ID
        this.userId = userId;
        this.title = title;
        this.content = content;
        this.date = date;
    }

    public Diary() {
        this.id = DEFAULT_ID++; // 确保默认构造函数也能生成ID
    }

    public int getId() {
        return id;
    }

    public int getUserId() {
        return userId;
    }

    public void setUserId(int userId) {
        this.userId = userId;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getDate() {
        return date;
    }

    public void setDate(String date) {
        this.date = date;
    }

    @NonNull
    @Override
    public String toString() {
        return "Diary{" +
                "id=" + id +
                ", userId=" + userId +
                ", title='" + title + '\'' +
                ", content='" + content + '\'' +
                ", date='" + date + '\'' +
                '}';
    }
}
